// 引入依赖的配置文件模块
require(["config"], function(){
	// 引入依赖模块
	require(["jquery","template", "header", "flexslider"], function($, template){
		function List(){
			this.renderList();
			this.flexslider();
		}
		List.prototype = {
			constructor: List,
			// 渲染列表数据
			renderList: function() {
				$.ajax("http://rap2api.taobao.org/app/mock/86944/api/list")
				.done(function(data) {
					// 待渲染的数据
					var data = {list: data.res_body.list};
					// 渲染
					var html = template("list_template", data);
					$("#ac-list").html(html);
				});
			},

			flexslider: function() {
				$('.flexslider').flexslider({
			        animation: "slide",
			        animationLoop: false,
			        itemWidth: 180,
			        itemMargin: 5,
			        minItems: 2,
			        maxItems: 5,
			        start: function(slider){
			           $('body').removeClass('loading');
			        }
			    });

			}
		}

		new List();
	});
});